package com.crm.common.result;


import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.List;

@AllArgsConstructor
@Data
public class PageResult {
    //总记录数
    private Long total;
    //列表数据
    private List<?> rows;
    //消息状态码
    private int code;
    //消息内容
    private String msg;
    //请求参数
    private Object params;


    public PageResult() {
    }


    public PageResult(long total, List<?> result) {
        this.total = total;
        this.rows =  result;
        this.code = 200;
        this.msg = "success";
    }
    public static PageResult success(long total, List<?> rows, Object params) {
        PageResult result = new PageResult(total, rows);
        result.setParams(params);
        return result;
    }


    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List<?> getRows() {
        return rows;
    }

    public void setRows(List<?> rows) {
        this.rows = rows;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
